package com.etc.sortdemo;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author: knowno
 * @create: 2024-09-11 13:43
 * @Version 1.0
 **/
public class ArraysSort {
    public static void main(String[] args) {

        int array[] = {1, 3, 5, 2, 4, 6, 9, 0};

        //1 针对于数组的排序的方法
        Arrays.sort(array);

        //排序后输出结果
        System.out.println(Arrays.toString(array));

        Integer array1[] = {1, 3, 5, 2, 4, 6, 9, 0};

        //    int compare(T o1, T o2);
        Arrays.sort(array1, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                // return o1.compareTo(o2);
                // return o1-o2;
                return o2 - o1;
            }
        });

        System.out.println(Arrays.toString(array1));

    }
}
